package cn.yzstu.api.api;


import cn.hutool.core.bean.BeanUtil;
import cn.yzstu.api.api.param.ActivityParam;
import cn.yzstu.api.domain.Activity;
import cn.yzstu.api.service.IActivityService;
import cn.yzstu.yzstubase.bean.Result;
import cn.yzstu.yzstubase.util.ResultGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author baldwin
 */
@RestController
@RequestMapping(value = "/api/v1/activity")
@Api(value = "活动相关api")
public class ActivityApi {

    @Autowired
    private IActivityService activityService;

    @ApiOperation(value = "添加一个活动")
    @PostMapping(value = "/addSave")
    public Result addSave(HttpServletRequest request, @ApiParam @RequestBody ActivityParam activityParam) {

        Activity insertActivity = new Activity();
        BeanUtil.copyProperties(activityParam, insertActivity);

        activityService.insertActivity(insertActivity);

        return ResultGenerator.genSuccessResult(insertActivity);
    }


}
